package com.ruoyi.controller;

import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.domain.Supplierinfo;
import com.ruoyi.service.ISupplierinfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * SupplierinfoController
 * 
 * @author wjy
 * @date 2025-01-11
 */
@RestController
@RequestMapping("/supplierinfo")
public class SupplierinfoController extends BaseController
{
    @Autowired
    private ISupplierinfoService supplierinfoService;

    /**
     * 查询Supplierinfo列表
     */
    @RequiresPermissions("supplierinfo:supplierinfo:list")
    @GetMapping("/list")
    public TableDataInfo list(Supplierinfo supplierinfo)
    {
        startPage();
        List<Supplierinfo> list = supplierinfoService.selectSupplierinfoList(supplierinfo);
        return getDataTable(list);
    }

    /**
     * 导出Supplierinfo列表
     */
    @RequiresPermissions("supplierinfo:supplierinfo:export")
    @Log(title = "Supplierinfo", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Supplierinfo supplierinfo)
    {
        List<Supplierinfo> list = supplierinfoService.selectSupplierinfoList(supplierinfo);
        ExcelUtil<Supplierinfo> util = new ExcelUtil<Supplierinfo>(Supplierinfo.class);
        util.exportExcel(response, list, "Supplierinfo数据");
    }

    /**
     * 获取Supplierinfo详细信息
     */
    @RequiresPermissions("supplierinfo:supplierinfo:query")
    @GetMapping(value = "/{supplierId}")
    public AjaxResult getInfo(@PathVariable("supplierId") Long supplierId)
    {
        return success(supplierinfoService.selectSupplierinfoBySupplierId(supplierId));
    }

    /**
     * 新增Supplierinfo
     */
    @RequiresPermissions("supplierinfo:supplierinfo:add")
    @Log(title = "Supplierinfo", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Supplierinfo supplierinfo)
    {
        return toAjax(supplierinfoService.insertSupplierinfo(supplierinfo));
    }

    /**
     * 修改Supplierinfo
     */
    @RequiresPermissions("supplierinfo:supplierinfo:edit")
    @Log(title = "Supplierinfo", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Supplierinfo supplierinfo)
    {
        return toAjax(supplierinfoService.updateSupplierinfo(supplierinfo));
    }

    /**
     * 删除Supplierinfo
     */
    @RequiresPermissions("supplierinfo:supplierinfo:remove")
    @Log(title = "Supplierinfo", businessType = BusinessType.DELETE)
	@DeleteMapping("/{supplierIds}")
    public AjaxResult remove(@PathVariable Long[] supplierIds)
    {
        return toAjax(supplierinfoService.deleteSupplierinfoBySupplierIds(supplierIds));
    }
}
